var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("GameEm"),
    s = t("ShopItemBuyReward1"),
    c = cc._decorator,
    p = c.ccclass,
    l =
        (c.property,
        c.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.checkCost = 0;
                e.parseKey = "";
                e.itemLast = [];
                e.rewardListData = [];
                e.spriteIcon = [];
                e.sendData = null;
                e.pageIndex = 0;
                e.sendLog = {
                    20101: "220101",
                    20102: "220102",
                    20111: "220111",
                    20112: "220112",
                    20113: "220113",
                    20121: "220121",
                    20122: "220122",
                    20123: "220123",
                    20124: "220124",
                    20131: "220131",
                    20132: "220132",
                    20133: "220133",
                    20134: "220134",
                    20141: "220141",
                    20142: "220142",
                    20143: "220143",
                    20144: "220144",
                    20145: "220145"
                };
                return e;
            }
            e.prototype.uplevelItem = function (t, e, o) {
                var a = this;
                this.sendData = t;
                this.spriteIcon.length = 0;
                this.pageIndex = e;
                this.parseKey = o;
                var i = (t.products + "").split("|"),
                    n = t.icon.split("|");
                this._costLab.$Label.string = "￥" + t.cash;
                this.checkCost = parseFloat(t.cash + "");
                this._BLab.$Label.string = t.discount + "%";
                this._costName.$Label.string = "" + t.name;
                this.scheduleOnce(function () {
                    a.spriteIcon.length = 0;
                    for (var o = 0; o < i.length; o++) {
                        var r = i[o],
                            c = a.itemLast[o] || QLooperNode.getNode(QLooperNode.tag_shopItemBuyReward1);
                        c.parent = a._rewardItem;
                        for (
                            var p = c.getComponent(s.default), l = p.setKindData(t, r, n[o], o, e), d = 0;
                            d < l.length;
                            d++
                        )
                            a.spriteIcon.push({
                                wpos: p.node.convertToWorldSpaceAR(cc.Vec2.ZERO),
                                path: l[d].path,
                                isZb: l[d].isZb,
                                idData: l[d].idData,
                                count: l[d].count
                            });
                        a.itemLast.push(c);
                    }
                });
            };
            e.prototype.udpatePos = function () {
                for (var t = 0; t < this.itemLast.length; t++)
                    this.spriteIcon[t] &&
                        (this.spriteIcon[t].wpos = this.itemLast[t].convertToWorldSpaceAR(cc.Vec2.ZERO));
            };
            e.prototype.clear = function () {
                for (var t = 0; t < this.itemLast.length; t++) QLooperNode.putNode(this.itemLast[t]);
            };
            e.prototype.checkSendKey = function () {
                var t = "" + this.sendLog[this.parseKey] || "";
                "" != t && QReport.send(t);
            };
            e.prototype._onBuyBtnTouchEnd = function () {
                var t = this;
                if (PayData.checkPayCost(this.checkCost)) {
                    this.udpatePos();
                    EVUIEffView.emit(EVUIEffView.udpateMovePageTime);
                    console.log(
                        "支付  发起",
                        this.parseKey + "++++++++++++++++++++++++++++++++" + this.spriteIcon.length
                    );
                    for (var e = [], o = 0; o < this.spriteIcon.length; o++)
                        if (this.spriteIcon[o].isZb)
                            for (var a = 0; a < this.spriteIcon[o].count; a++)
                                e.push({id: this.spriteIcon[o].idData, num: 1});
                        else {
                            var i = this.spriteIcon[o].idData;
                            if ("2" == i) e.push({id: 1, num: this.spriteIcon[o].count});
                            else
                                switch (i) {
                                    case "5":
                                    case "6":
                                    case "7":
                                        e.push({id: i, num: this.spriteIcon[o].count});
                                }
                        }
                    PayData.addPayData(
                        this.parseKey,
                        this.checkCost,
                        function (e) {
                            if (e) {
                                console.log("支付  回调", t.parseKey + "++++++++++++++++++++++++++++++++");
                                console.log(
                                    "支付  回调奖励",
                                    t.parseKey + "++++++++++++++++++++++++++++++++" + t.spriteIcon.length
                                );
                                t.checkSendKey();
                                GameDataValue.openShopItemData(0, t.pageIndex);
                                CacheDataManager.getCostumeup();
                                var o = "";
                                t.sendData && t.sendData.name && (o = t.sendData.name);
                                for (
                                    var a = {resId: t.parseKey, count: t.checkCost, type: 2, tip: "折扣礼包", tip2: o},
                                        i = [],
                                        n = 0;
                                    n < t.spriteIcon.length;
                                    n++
                                ) {
                                    var s = t.spriteIcon[n].wpos,
                                        c = cc.v2(s).add(cc.v2(-100, 1300));
                                    EVUIEffView.emit(EVUIEffView.movePropSpriteIcon, s, c, t.spriteIcon[n].path, !0);
                                    EVUIEffView.emit(EVUIEffView.udpateMovePageTime);
                                    if (t.spriteIcon[n].isZb) {
                                        console.log(
                                            "ShopPageItem ----------------- 添加 装备 :" +
                                                t.spriteIcon[n].idData +
                                                "数量" +
                                                t.spriteIcon[n].count
                                        );
                                        for (var p = 0; p < t.spriteIcon[n].count; p++) {
                                            GameDataValue.addEquip(t.spriteIcon[n].idData);
                                            i.push({id: t.spriteIcon[n].idData, num: 1});
                                        }
                                    } else {
                                        var l = t.spriteIcon[n].idData;
                                        if ("2" == l) {
                                            console.log(
                                                "ShopPageItem ----------------- 添加 钻石 资源 " +
                                                    t.spriteIcon[n].idData +
                                                    ">" +
                                                    t.spriteIcon[n].count
                                            );
                                            GameDataValue.setPropCount(
                                                r.PropKind.zhuanshi,
                                                GameDataValue.getPropCount(r.PropKind.zhuanshi) + t.spriteIcon[n].count
                                            );
                                            i.push({id: 1, num: t.spriteIcon[n].count});
                                        } else
                                            switch (l) {
                                                case "5":
                                                case "6":
                                                case "7":
                                                    console.log(
                                                        "ShopPageItem ----------------- 添加 宝箱 资源 " +
                                                            t.spriteIcon[n].idData +
                                                            ">" +
                                                            t.spriteIcon[n].count
                                                    );
                                                    i.push({id: l, num: t.spriteIcon[n].count});
                                                    GameDataValue.addRewardKind(l, t.spriteIcon[n].count);
                                            }
                                    }
                                }
                                PayData.addLog(a.resId, a.count, a.type, i, a.tip, a.tip2);
                                t.scheduleOnce(function () {
                                    EVUIEffView.emit(EVUIEffView.udpateShopPage);
                                });
                            }
                        },
                        e
                    );
                }
            };
            return n([p], e);
        })(Thor));
o.default = l;
